#ifndef CONNECTION_H
#define CONNECTION_H

#include <QObject>
#include <QTcpSocket>

class HttpServer;

class Connection : public QObject
{
Q_OBJECT
public:
    Connection(HttpServer* parent, QTcpSocket* sock);
    void handle();

private:
    void sendList();
    void sendFile(QString uri);
    void sendIndex();

    void sendTrackPlaylist(QString uri, QString host);
    void sendAlbumPlaylist(QString uri, QString host);
    void sendArtistPlaylist(QString uri, QString host);

    QTcpSocket* sock;
    QByteArray request;
    bool requestIsComplete();
    void executeRequest();
    HttpServer* server;

signals:

public slots:

private slots:
    void readNext();
    void bytesWritten();
};

#endif // CONNECTION_H
